/*
* File: TaskOutputViewer.java
* Author: Daniel Rogers
* Created on Jan 28, 2008
*
*/
package gri.tasks.gui;
import java.awt.BorderLayout;
import javax.swing.*;
import gri.tasks.ParameterDef;
import gri.tasks.TaskDef;
import gri.tasks.gui.widgets.OutputParameterWidgetFactory;
import gri.tasks.gui.widgets.ParameterWidgetFactory;
import gri.tasks.gui.util.JobEntry;
import java.util.Map;
/**
* Displays the outputs of a job in a new frame
*
* @author dan.rogers
*/
public class TaskOutputViewer implements JobViewer {
ParameterWidgetFactory widgetFactory;
// --------------------------------------------------------- Constructors
public TaskOutputViewer(ParameterWidgetFactory widgetFactory) {
this.widgetFactory = widgetFactory;
}
public TaskOutputViewer() {
this(new OutputParameterWidgetFactory());
}
// ---------------------------------------------------------- Implementation
public void showJob(JobEntry job) {
//System.out.println(task.getId());
//print outputs:
Map outputs = job.getController().getOutputs();
TaskDef taskDef = job.getTaskDef();
ParameterDef [] params = (ParameterDef [])taskDef.getOutputs().toArray(
new ParameterDef[0]);
for (int i=0; i<params.length; i++) {
ParameterDef paramDef = params[i];
Object value = outputs.get(paramDef.getName());
System.out.println(value + " (" + paramDef.getDataType() + ")");
}
//display outputs:
JFrame frame = new JFrame("Outputs");
ParameterPanel outPanel = new ParameterPanel(params, widgetFactory);
outPanel.setValues(outputs);
JScrollPane outPanel_scroll = new JScrollPane(outPanel);
frame.getContentPane().add(outPanel_scroll, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}